/*
 * SimulatedDisk.h
 *
 *  Created on: Jul 6, 2009
 *      Author: yanir
 */

#ifndef SIMULATEDDISK_H_
#define SIMULATEDDISK_H_

#include <fstream>
#include <sstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

using namespace std;

class SimulatedDisk {

private:


	int _fd ; //file descriptor for FILE_SYS

	int _intSize;
	int _charSize;
	int _pointerSize;
	int _iNodeSize;


	int _adressBlockInodsAd; // number of additional needed blocks for the free i nodes addresses
	int _adressBlocksFreeAd; //  number of additional needed blocks for the free blocks addresses

	int _freeBlistend;        //pointer to the end of the free blocks list
	int _freeInodeListend;   //pointer to the end of the free i nodes list


/* SUPER BLOCK DATA */

// 1.General Data

	int _dataDiskSize;   // The size of the file system (in blocks)
	int _blockSize;      //   The size of a block (in bytes, minimum size is 64 bytes)
	int _root_Inode;   // Number of root i-node.

	int _iNodesNum;  //Number of i nodes.

// 2.Block Control

	int _freeBlocksNum; // the number of free blocks in the file system





public:
	SimulatedDisk();

	SimulatedDisk(string config_file);

	/** creates FILE_SYS **/
	void createDisk();

	/** creates the general data **/
	void create_General_Data();

	/** creates block control **/
	void create_block_control();

	/** creates i-Node control **/
	void create_iNode_control();

	/** creates the list of free i nodes addresses **/
	void create_FiNode_list();

	/** creates the list of free blocks **/
	void create_Fblocks_list();

	/** creates the inodes array **/
	void create_iNods_array();

	/** creates free blocks **/
	void create_freeBlocks();


	virtual ~SimulatedDisk();


	/**will split a string into 2 **/
	void splitstring(string str, string seperater, string &first, string &second);

	string strWord( string line);



};




#endif /* SIMULATEDDISK_H_ */
